﻿using Microsoft.InformationProtectionAndControl;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Configuration;

namespace CloudStorageLight.Core
{
    public static class BlobUtil
    {
        public static int MaxUrlLength
        {
            get
            {
                return (ConfigurationManager.GetSection("system.web/httpRuntime") as HttpRuntimeSection).MaxUrlLength;
            }
        }

        public static int MaxFileLength { get { return Math.Max(260,MaxUrlLength - 200); } }
        public static int MaxFolderLength { get { return Math.Max(260, MaxFileLength - 300); } }

        public static string UnescapeDataString(string path)
        {
            return Uri.UnescapeDataString(path);
        }

        public static bool IsValidPath(string path)
        {
            return !Path.GetInvalidFileNameChars().Any(x => path.Contains(x));
        }

    }
}
